define(['jquery'], () => {
    const baseUrl_link = 'http://www.xiongmaoyouxuan.com/api/tabs'
    const baseUrl_shopList="http://www.xiongmaoyouxuan.com/api/tab/"
    const baseUrl_indexList='http://www.xiongmaoyouxuan.com/api/tab/1'
    const baseUrl_bannerList="http://www.xiongmaoyouxuan.com/api/column"
    const baseUrl_searchList='http://www.xiongmaoyouxuan.com/api/search?word='
    const baseUrl_detail='http://www.xiongmaoyouxuan.com/api/detail?id='
   
    // 基于jquery的get请求封装了一个promise
    const get = (url, data) => {
      return new Promise((resolve, reject) => {
        $.get(url, data, resp => {
          resolve(resp)
        })
      })
    }
  
    return {
      getLink () {
        return get(baseUrl_link)
      },
      getShopList (id) {
        return get(baseUrl_shopList+id)
      },
      getIndexList(){
          return get(baseUrl_indexList)
      },
      getBannerList(id){
          return get(baseUrl_bannerList+id+'/items')
      },
      getSearchList(word){
          return get(baseUrl_searchList+word+'&start=0&sort=0&couponOnly=NaN&minPrice=0&maxPrice=99999')
      },
      getNavList(){
          return get('http://www.xiongmaoyouxuan.com/api/search/home')
      },
      getBannerAcitve(id){
        return get(`http://www.xiongmaoyouxuan.com/api/column/${id}/items?start=0`)
      },
      getDetail(id){
        return get(baseUrl_detail+id)
      },
      getUpdata(num,id,word){
        if(location.search.includes('search')){
          return get(`http://www.xiongmaoyouxuan.com/api/search?word=${word}&start=${num}`)
        }else if(location.search.includes('id')){
          return get(`http://www.xiongmaoyouxuan.com/api/tab/${id}/feeds?start=${num}`)
        }
      }
    }
  })